import java.util.Arrays;

class Student implements Comparable<Student>{
    public String name;
    public int age;

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    public int compareTo(Student o) {
        return this.age-o.age;
    }
}

public class Test {
    public static void main(String[] args) {
        Student[] students=new Student[]{
                new Student("zhansan",18),
                new Student("man",24),
                new Student("lebron",23)
        };
        NameComparator nameComparator=new NameComparator();
        AgeComparator ageComparator=new AgeComparator();
        Arrays.sort(students,nameComparator);
        System.out.println(Arrays.toString(students));

    }
}
